function copyAttributes(from, to)
{
    for (a=0; a<from.attributes.length; a++){
        if (from.attributes[a].specified) {
            name = from.attributes[a].nodeName;
            value = from.getAttribute(name);
            to.setAttribute(name, value);
        }
    }
}
function copyRow(rowFrom, rowTo)
{
    cells = rowFrom.getElementsByTagName('td');
    for(c=0; c<cells.length; c++) {
        newCell = rowTo.insertCell(-1);
        copyAttributes(cells[c], newCell)
        newCell.innerHTML = cells[c].innerHTML;
    }
}
function appendTable(tableFrom, tableTo)
{
    rows = tableFrom.getElementsByTagName('tr');
    for (r=0; r<rows.length; r++) {
        newRow = tableTo.insertRow(-1);
        copyAttributes(rows[r], newRow);
        copyRow(rows[r], newRow);
    }
    return rows.length;
}
function insertTable(tableFrom, tableTo, position)
{
    rows = tableFrom.getElementsByTagName('tr');
    for (r=0; r<rows.length; r++) {
        newRow = tableTo.insertRow(position+r+1);
        copyAttributes(rows[r], newRow);
        copyRow(rows[r], newRow);
    }
    return rows.length;
}